<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <script>
        // es5写法
        var name = 'tom';
        var age = 13;
        var obj = {
            name:name,
            age:age
        }
        console.log(obj);

        // es6语法:属性的简写
        var name = 'tom';
        var age = 13;
        var obj2 = {
            name,
            age
        }
        console.log(obj2);

        console.log('0----------0');

        // es5写法
        var name = 'tom';
        var age = 13;
        var obj3 = {
            name:name,
            age:age,
            sayAddress:function(){
                console.log('广西');
                return '广西'
            }
        }
        console.log(obj3);
        console.log(obj3.sayAddress(),'===')
        // 等价于
        // var res = obj3.sayAddress()
        // console.log(res,'===')

        
        // es6写法：方法的简写
        var name = 'tom';
        var age = 13;
        var obj4 = {
            name,
            age,
            sayAddress(){
                console.log('广西');
            }
        }
        console.log(obj4);





    </script>
</body>
</html>